from typing import List

from modules.amis.component.base import SchemaNode, Level, Action, EmptySchema, BaseSchema, Size, ActionType, SchemaType


class Dialog(BaseSchema):
    def __init__(self,
                 type: SchemaType = ActionType.button,
                 title: SchemaNode = None,
                 body: SchemaNode = None,
                 bodyClassName: str = None,
                 closeOnEsc: bool = None,
                 showCloseButton: bool = None,
                 showErrorMsg: bool = None,
                 showLoading: bool = None,
                 disabled: bool = None,
                 actions: any = None,
                 data: object = None,
                 size: Size = None,
                 **kwargs,
                 ):
        super().__init__()
        self.actionType = "dialog"
        self.type: SchemaType = type
        self.title: SchemaNode = title
        self.body: SchemaNode = body
        self.size: Size = size
        self.bodyClassName: str = bodyClassName
        self.closeOnEsc: bool = closeOnEsc
        self.showCloseButton: bool = showCloseButton
        self.showErrorMsg: bool = showErrorMsg
        self.showLoading: bool = showLoading
        self.disabled: bool = disabled
        self.actions: any = actions
        self.data: object = data
        for key, value in kwargs.items():
            self.__dict__[key] = value


class Alert(BaseSchema):
    def __init__(self,
                 title: SchemaNode = "",
                 body: SchemaNode = EmptySchema,
                 className: str = "",
                 level: Level = Level.none,
                 showCloseButton: bool = True,
                 closeButtonClassName: str = "",
                 showIcon: bool = False,
                 icon: str = "",
                 iconClassName: str = "",
                 actions: List[Action] = None,
                 **kwargs,
                 ):
        super().__init__()
        self.type = "alert"
        self.title: SchemaNode = title
        self.className: str = className
        self.bodyClassName: str = className
        self.body: SchemaNode = body
        self.showCloseButton: bool = showCloseButton
        self.level: Level = level
        self.closeButtonClassName: str = closeButtonClassName
        self.showIcon: bool = showIcon
        self.actions: any = actions
        self.icon: object = icon
        self.iconClassName: str = iconClassName
        for key, value in kwargs.items():
            self.__dict__[key] = value


class Feedback(BaseSchema):
    def __init__(self,
                 title: SchemaNode = "",
                 body: SchemaNode = EmptySchema,
                 **kwargs,
                 ):
        super().__init__()
        self.title: SchemaNode = title
        self.body: SchemaNode = body
        for key, value in kwargs.items():
            self.__dict__[key] = value